package com.example.mediacore.player;

/**
 * 播放器状态枚举（与Native层MediaState严格对应）
 */
public enum PlayerState {
    IDLE(0),        // 初始状态
    READY(1),       // 就绪
    RUNNING(2),     // 播放中
    PAUSED(3),      // 已暂停
    STOPPED(4),     // 已停止
    ERROR(5);       // 错误状态

    private final int nativeCode;

    PlayerState(int nativeCode) {
        this.nativeCode = nativeCode;
    }

    /**
     * 根据Native层返回的int值转换为枚举
     */
    public static PlayerState fromNativeCode(int nativeCode) {
        for (PlayerState state : values()) {
            if (state.nativeCode == nativeCode) {
                return state;
            }
        }
        throw new IllegalArgumentException("Invalid native state code: " + nativeCode);
    }

    /**
     * 获取对应的Native层int值
     */
    public int getNativeCode() {
        return nativeCode;
    }
}